package ControleDiversas;

import java.sql.ResultSet;
import java.sql.SQLException;
import JBCD.MetodoConexao;
import VisaoControleAcademico.PainelPrincipal;

public class PesquisarTurma {
	
	public PesquisarTurma() {
		PainelPrincipal.modelo.removeAllElements();
		String P = PainelPrincipal.textPesquisaTurma.getText();
		MetodoConexao.conctarBanco();
		try {
			ResultSet RS = MetodoConexao.coneck.executeQuery("SELECT * FROM turma");
			if (P != null) {
				while (RS.next()) {
					if (P.equals(RS.getString("descricao").trim())) {
						PainelPrincipal.modelo.addElement(RS.getString("descricao").trim());
					}

				}
			}

			MetodoConexao.con.close();
		} catch (SQLException ef) {
			ef.printStackTrace();
		}
	}
	
	
public static void adicionarJListTurma(){
	PainelPrincipal.modelo.removeAllElements();
	MetodoConexao.conctarBanco();
	try {
		ResultSet RS = MetodoConexao.coneck.executeQuery("SELECT * FROM turma ORDER BY descricao");
			while (RS.next()) {
				PainelPrincipal.modelo.addElement(RS.getString("descricao").trim());
		}
			MetodoConexao.con.close();
	} catch (SQLException ef) {
		ef.printStackTrace();
	}
	

	}

}
